using Microsoft.Xna.Framework;

namespace RpgXna.Model.Helpers
{
    internal static class Transforms
    {
        public static Vector2 TransformPoint(Vector2 p, Vector2 pos, float a, Vector2 origin, float s = 1f)
        {
            Matrix wm = Matrix.CreateTranslation(-pos.X - origin.X, -pos.Y - origin.Y, 0)
                //set the reference point to world reference taking origin into account
                        * Matrix.CreateScale(s)
                        * Matrix.CreateRotationZ(a) //rotate
                        * Matrix.CreateTranslation(pos.X, pos.Y, 0); //translate back

            Vector2 rp = Vector2.Transform(p, wm);
            return rp;
        }
    }
}